package com.shujia.student;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.HashMap;

public class ClazzCount {
    public static void main(String[] args) throws Exception {


        long start = System.currentTimeMillis();

        FileReader fileReader = new FileReader("java/data/big_student.txt");
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        HashMap<String, Long> map = new HashMap<>();

        String line;
        while ((line = bufferedReader.readLine()) != null) {
            String clazz = line.split(",")[4];

            Long aLong = map.get(clazz);
            if (aLong != null) {
                map.put(clazz, aLong + 1);
            } else {
                map.put(clazz, 1L);
            }
        }

        System.out.println(map);
        bufferedReader.close();
        fileReader.close();

        long end = System.currentTimeMillis();

        System.out.println(end - start);

    }
}
